package com.jz.netthings.system.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.jz.netthings.annotation.AdscmLogger;
import com.jz.netthings.bean.AdscmLogEntity;
import com.jz.netthings.bean.system.JyDept;
import com.jz.netthings.exception.AdscmSystemException;
import com.jz.netthings.security.support.SimpleResponse;
import com.jz.netthings.system.service.JyLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yyy
 * @ClassName AdscmLogController
 * @Description 操作日志Controller
 * @date 2018/8/2 17:40
 */
@RestController
@CrossOrigin
@RequestMapping("/adscm/system/log")
public class AdscmLogController {

    Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    JyLogService jyLogService;

    /**
     * 分页查询系统日志
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("/allLog/{currentPage}/{pageSize}")
    @AdscmLogger("分页查询系统日志")
    public SimpleResponse getAllLogPage(@PathVariable int currentPage, @PathVariable int pageSize) throws AdscmSystemException{

        Page<AdscmLogEntity> page = new Page<AdscmLogEntity>(currentPage,pageSize);

        page = jyLogService.selectPage(page);
        page.setTotal(jyLogService.selectCount(null));

        return new SimpleResponse("200","分页查询系统日志成功",page);
    }

}
